﻿using System;

using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace Silvermoon.Controls
{
    /// <summary>
    /// EventArgs for pan events.
    /// </summary>
    public class PanEventArgs : CancelEventArgs
    {
        /// <summary>
        /// Gets or sets the start point to calculate the value for OnPan events.
        /// </summary>
        /// <see>
        /// See Pivot.PanInternal() for example usage.
        /// </see>
        public Point StartPoint { get;  set; }

        /// <summary>
        /// Default Deceleration.
        /// </summary>
        public const float DefaultDeceleration = 0.0001F;

        /// <summary>
        /// Initializes a new instance of the <see cref="PanEventArgs"/> class.
        /// </summary>
        /// 
        public PanEventArgs()
            : base()
        {
        }

        /// <summary>
        /// Gets or sets the current value. Set this value at Control.OnBeginPan to the current point to be panned, and
        /// read this value at Control.OnPan to set the value to be panned.
        /// </summary>
        public Point Value;

        /// <summary>
        /// Gets the direction to be panned.
        /// Check this property at Control.OnBeginPan to determine whether to set Handled to true to receive PanEventArgs at Control.OnPan
        /// </summary>
        public PanDirection Direction { get; internal set; }

        public bool HorizontalMotion
        {
            get { return (Direction & PanDirection.Horizontal) != 0; }
        }

        public bool VerticalMotion
        {
            get { return (Direction & PanDirection.Vertical) != 0; }
        }

        /// <summary>
        /// Gets the relative position of the touch point relative to the top left edge of the control.
        /// </summary>
        public Point Position { get; private set; }

        /// <summary>
        /// Helper method for message server.
        /// </summary>
        internal void SetValue(int dx, int dy, Point position)
        {
            Value = new Point(StartPoint.X + dx, StartPoint.Y - dy);
            Position = position;
        }
    }
}
